package com.javasm.service.Impl;

import com.alibaba.fastjson.JSON;
import com.javasm.dao.AdminMenuDao;
import com.javasm.entity.AdminMenu;
import com.javasm.service.adminMenuService;
import com.javasm.utils.MybatisHealper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class adminMenuServiceImpl implements adminMenuService {
    @Override
    public List<AdminMenu> ListMenuByCondition(AdminMenu inputMenu, Integer page, Integer pageSize) {
        SqlSession sqlSession  = MybatisHealper.getsqlsession();
        AdminMenuDao mapper = sqlSession.getMapper(AdminMenuDao.class);


        List<AdminMenu> adminMenus = mapper.ListMenuByCondition(inputMenu,(page-1)*pageSize,pageSize);
        MybatisHealper.backAndSaveSqlSession(sqlSession);
        return adminMenus;
    }

    @Override
    public Integer countMenuByDao(AdminMenu inputMenu) {
        SqlSession sqlSession  = MybatisHealper.getsqlsession();
        AdminMenuDao mapper = sqlSession.getMapper(AdminMenuDao.class);


        Integer resNum = mapper.countMenuByDao(inputMenu);
        MybatisHealper.backAndSaveSqlSession(sqlSession);
        return resNum;
    }
}
